const Koa = require('koa');

/**
 * 第三方中间件
 */
const cors = require('@koa/cors');
const static = require('koa-static');
const body = require('koa-body');
const path = require('path');

/**
 * 自定义模块
 */
const router = require('./route/index');
const { PORT } = require('./const');

const app = new Koa();

app.use(body());
app.use(cors());
app.use(static(path.relative(__dirname, './target')));

app.use(router.routes());
app.use(router.allowedMethods());
app.listen(PORT, () => {
    console.log(`serve start at ${PORT}`);
});